const express = require('express');
const app = express();

const bodyParser = require('body-parser');

app.use(express.static('public'));

app.use(bodyParser.urlencoded({ extended: true }));


const user = {};
const user1 = {};
// app.use('*', function(req, res, next) {
//     // res.setHeader('Access-Control-Allow-Origin', 'http://127.0.0.1:8020');
//     res.setHeader('Access-Control-Allow-Origin', '*')
//     res.setHeader('Access-Control-Allow-Methods', '*')
//     res.setHeader('Access-Control-Allow-Headers', 'content-type')
//     next()
// })
app.post('/zhuce', (req, res) => {
    console.log(req.body);
    user.name = req.body.name;
    user.password = req.body.password;
    res.send('注册成功');
})
app.post('/denglu', (req, res) => {
    user1.name = req.body.name;
    user1.password = req.body.password;
    if (user.name == user1.name && user.password == user1.password) {
        res.send('登录成功');
    } else {
        res.send('登录失败，账号或密码错误');
    }
})
app.get('/pc', (req, res) => {

    res.send('pc')
})
app.listen(3000, err => {
    if (!err) console.log('服务器启动成功！！');
    else console.log(err);
})